﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using UICommon.ExtendController;
using UICommon.ExtendHtmlHelper;

namespace ConvertMediaPro.Controllers
{
    public class UploadController : Controller
    {
        //
        // GET: /Upload/
        public ActionResult Index()
        {
            Int64 returnFilePath = 0;

            if (Request.Files["imgFile"].HasFile())
            {
                returnFilePath = SaveResource(Request.Files["imgFile"]); 
            }

            return Json(new { error = 0, url = "/FileProcess/DownLoad/" + returnFilePath }, JsonRequestBehavior.AllowGet);//Content(string.Format("{0}", returnFilePath));
        }

        /// <summary>
        /// 保存文件
        /// </summary>
        /// <param name="file"></param>
        /// <param name="parentKey"></param>
        /// <returns></returns>
        public Int64 SaveResource(HttpPostedFileBase file)
        {
            FileProcessController fileProcess = new FileProcessController();

            return fileProcess.SaveResource(file);
        }
	}
}